/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Starter.java
 *
 * Created on 27 mai 2010, 16:14:10
 */

/**
 *
 * @author saluzzo
 */
public class Starter extends javax.swing.JFrame {



    /** Creates new form Starter */
    public Starter() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        j1Type = new javax.swing.JComboBox();
        j2Type = new javax.swing.JComboBox();
        j2Heuristique = new javax.swing.JComboBox();
        j2Niveau = new javax.swing.JComboBox();
        j1Niveau = new javax.swing.JComboBox();
        j1Heuristique = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        ActiverMusic = new javax.swing.JToggleButton();
        LancerLeJeux = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Othello Starter");

        jLabel1.setText("Blanc");

        jLabel2.setText("Noir");

        j1Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Humain", "Automate" }));
        j1Type.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                j1TypeActionPerformed(evt);
            }
        });

        j2Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Humain", "Automate" }));
        j2Type.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                j2TypeActionPerformed(evt);
            }
        });

        j2Heuristique.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "miniMax", "maxiMin" }));

        j2Niveau.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3" }));

        j1Niveau.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3" }));

        j1Heuristique.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "miniMax", "maxiMin" }));

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Type de Joueur");

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Heuristique");

        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText("Niveau");

        ActiverMusic.setText("Activer Music");
        ActiverMusic.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ActiverMusicActionPerformed(evt);
            }
        });

        LancerLeJeux.setText("Lancer le Jeux");
        LancerLeJeux.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LancerLeJeuxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(LancerLeJeux, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)
                                    .addComponent(j1Type, 0, 121, Short.MAX_VALUE))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel4, 0, 0, Short.MAX_VALUE)
                                    .addComponent(j1Heuristique, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(j2Type, 0, 121, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(j2Heuristique, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(j2Niveau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5, 0, 0, Short.MAX_VALUE)
                            .addComponent(j1Niveau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(15, 15, 15))
                    .addComponent(ActiverMusic, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(j1Heuristique, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(j1Niveau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(j1Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(j2Niveau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(j2Heuristique, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(j2Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(ActiverMusic)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LancerLeJeux, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void j1TypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j1TypeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_j1TypeActionPerformed

    private void j2TypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j2TypeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_j2TypeActionPerformed

    private void ActiverMusicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ActiverMusicActionPerformed
        if(this.ActiverMusic.isSelected()) {
            //On lance la music
            etbam = new Audio();
            etbam.start();
        } else {
            //On eteint la music
            etbam.arrete();
            etbam = null;
        }
    }//GEN-LAST:event_ActiverMusicActionPerformed

    private void LancerLeJeuxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LancerLeJeuxActionPerformed
        // TODO code application logic here
        // création d'un plateau
        plateau = new Plateau();
        //déclaration des joueurs

        int Type, Heuristique, Niveau;
        if(j1Type.getSelectedItem() == "Automate") {
            Type = Constantes.AUTOMATE;
        } else {
            Type = Constantes.HUMAIN;
        }
        if(j1Heuristique.getSelectedItem() == "miniMax") {
            Heuristique = 1;
        } else {
            Heuristique = 2;
        }
        Niveau = Integer.parseInt((String)j1Niveau.getSelectedItem());
        joueur1 = new Joueur(Constantes.BLANC, plateau,Type, Heuristique, Niveau);



        if(j2Type.getSelectedItem() == "Automate") {
            Type = Constantes.AUTOMATE;
        } else {
            Type = Constantes.HUMAIN;
        }
        if(j2Heuristique.getSelectedItem() == "miniMax") {
            Heuristique = 1;
        } else {
            Heuristique = 2;
        }
        Niveau = Integer.parseInt((String)j2Niveau.getSelectedItem());
        joueur2=new Joueur(Constantes.NOIR, plateau,Type, Heuristique, Niveau);

        //création de l'IHM du plateau
        ihm = new newIHM(plateau, joueur1, joueur2);
        //association de l'IHM au plateau
        plateau.setInterface(ihm);

        ihm.changeImage();
    }//GEN-LAST:event_LancerLeJeuxActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Starter().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToggleButton ActiverMusic;
    private javax.swing.JButton LancerLeJeux;
    private javax.swing.JComboBox j1Heuristique;
    private javax.swing.JComboBox j1Niveau;
    private javax.swing.JComboBox j1Type;
    private javax.swing.JComboBox j2Heuristique;
    private javax.swing.JComboBox j2Niveau;
    private javax.swing.JComboBox j2Type;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    // End of variables declaration//GEN-END:variables

    private Audio etbam;
    private newIHM ihm;
    private Plateau plateau;
    private Joueur joueur1;
    private Joueur joueur2;
}
